﻿using System.ComponentModel.DataAnnotations;
using CID.Domain;

namespace CID.Web.Models
{
    public abstract class BaseDescribedViewModel<T> : BaseNamedViewModel<T>, IDescribedViewModel
        where T:IDescribedEntity
    {
        [Required(ErrorMessage = "You must provide a description")]
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }

        public BaseDescribedViewModel() : base() { }

        public BaseDescribedViewModel(T model) : base(model)
        {
            Description = model.Description;
        }

        public override void UpdateModel(T model)
        {
            base.UpdateModel(model);
            model.Description = Description;
        }
    }
}